package com.hbl.cgs.cgsagent.plugin;

import java.util.Map;

public abstract class AbstractInputPlugin implements InputPlugin{
    private String name;
    protected FilterPlugin filter;
    protected EventQueue dataQueue;
    protected LifecycleState lifecycleState;
    protected Map<String, String> context;

    public AbstractInputPlugin() {
        this.lifecycleState = LifecycleState.STOP;
    }

    @Override
    public void start() {
        if (LifecycleState.START.equals(lifecycleState)) {
            return;
        }
        filter.start();
        lifecycleState = LifecycleState.START;
    }

    @Override
    public void stop() {
        if (LifecycleState.STOP.equals(lifecycleState)) {
            return;
        }
        filter.stop();
        lifecycleState = LifecycleState.STOP;
    }

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public void configure(Map<String, String> context) {
        this.context = context;
    }

    @Override
    public LifecycleState getLifecycleState() {
        return this.lifecycleState;
    }
}
